﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Shop.Controllers
{
    public class MyAdminController : Controller
    {
        // GET: MyAdmin
        public ActionResult Index()
        {
            var admin1 = (List<Shop.Domain.NewFolder1.Administrator1Model>)Session["Admin1"];
            if (admin1 == null)
            {
                return RedirectToAction("Index");
            }
            ViewBag.Admin1 = admin1;
            return View();
        }
        public ActionResult Indent()
        {
            return View();
        }
        Shop.Service.LoginService.LoginService server = new Service.LoginService.LoginService();
        public JsonResult check(string pars)
        {
            try
            {
                if (pars!=""&&pars!=null)//有数据查询数据库
                {
                    var para = server.GetIndent(pars);
                    return Json(new { para });
                }
                else
                {
                    var para = server.GetIndent();
                    return Json(new { para });//返回json数据
                }
            }
            catch (Exception e)
            {
                return Json(new { flag="查询出错！" });
            }
        }//订单查看
        public JsonResult MyAccount()
        {
            var admin1 = (List<Shop.Domain.NewFolder1.Administrator1Model>)Session["Admin1"];
            return Json(new { admin1 });
        }
        public JsonResult ChangeName(Shop.Domain.NewFolder1.Administrator1Model s) {
            try
            {
                var dd = server.GetAdmin(s);
                dd.AdminName = s.AdminName;
                dd.AdminPassword = s.AdminPassword;
                server.EditAdmin(dd);
                return Json(new { map="修改成功"});
            }
            catch (Exception)
            {

                return Json(new {map="修改失败" });
            } 

        }//修改人资料
        public ActionResult DongXiShangJia(){
            return View();
        }
        public ActionResult LeiXing() {
            return View();
        }
    }
}